package com.yztstudy.Controller;

import com.yztstudy.Service.ProductService;
import com.yztstudy.entity.Product;
import com.yztstudy.param.ProductSearchParam;
import com.yztstudy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商品搜索的表示层
 */

@RestController
@RequestMapping("/product")
public class ProductSearchController {

    @Autowired
    private ProductService productService;

    /**
     * TODO 搜索服务,获取全部商品数据,用于同步到ES服务
     * @return
     */
    @GetMapping("/list")
    public List<Product> allList()
    {
        return productService.allList();
    }


    /**
     * TODO 搜索功能
     * @param productSearchParam 前端发来的搜索参数
     * @return
     */
    @PostMapping("/search")
    public R search(@RequestBody ProductSearchParam productSearchParam)
    {
        return productService.search(productSearchParam);
    }
}
